package org.liuwei.concucrent.base02_cas.UnsafeArrayList_08;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @Title: UnsafeArrayList.java
 * @Package org.liuwei.concucrent.base10
 * @Description: TODO(测试非线程安全的ArrayList)
 * @author 刘伟 15818570028@163.com
 * @date 2016年8月20日 下午12:19:22
 * @version V1.0
 */
public class UnsafeArrayList {
	ArrayList al = new ArrayList();
	Map m = new HashMap();

	public static void main(String[] args) throws InterruptedException {
		new UnsafeArrayList().test();
	}

	public void test() {
		
		
		Thread t1 = new Thread(new AddTask(), "t1");
		Thread t2 = new Thread(new AddTask(), "t2");
		t1.start();
		t2.start();
		
	}

	class AddTask implements Runnable {
		public void run() {
			for (int i = 0; i < 1000000; i++) {
				al.add(i);
				// m.put("i", "i");
			}

		}
	}

}